// https://umijs.org/config/
import { defineConfig, history } from 'umi';
import defaultSettings from './defaultSettings';
import proxy from './proxy';
import routes from './router';
const { REACT_APP_ENV } = process.env;
export default defineConfig({
  hash: true,
  antd: {},
  dva: {
    hmr: true,
  },
  history: { type: 'hash' },
  locale: {
    // default zh-CN
    default: 'zh-CN',
    // default true, when it is true, will use `navigator.language` overwrite default
    antd: true,
    baseNavigator: true,
  },
  // dynamicImport: {
  //   loading: '@/components/Loading/index',
  // },
  targets: {
    ie: 9,
  },
  // 配置 external
  externals: {
    react: 'window.React',
    'react-dom': 'window.ReactDOM',
    bizcharts: 'BizCharts',
    'pdfjs-dist': 'pdfjsLib',
    'pdf.worker.js': 'pdfjsWorker',
    'js-export-excel':'window["js-export-excel"]'
  },
  // 引入被 external 库的 scripts
  // 区分 development 和 production，使用不同的产物
  scripts:
    process.env.NODE_ENV === 'development'
      ? [
          'https://gw.alipayobjects.com/os/lib/react/16.13.1/umd/react.development.js',
          'https://gw.alipayobjects.com/os/lib/react-dom/16.13.1/umd/react-dom.development.js',
          'https://gw.alipayobjects.com/os/lib/bizcharts/4.0.14/umd/BizCharts.js',
          'https://cdn.bootcdn.net/ajax/libs/pdf.js/2.2.228/pdf.js',
          'https://cdn.bootcdn.net/ajax/libs/pdf.js/2.2.228/pdf.worker.js',
          'https://cdn.jsdelivr.net/npm/js-export-excel@1.1.4/lib/index.min.js'
        ]
      : [
          'https://gw.alipayobjects.com/os/lib/react/16.13.1/umd/react.production.min.js',
          'https://gw.alipayobjects.com/os/lib/react-dom/16.13.1/umd/react-dom.production.min.js',
          'https://gw.alipayobjects.com/os/lib/bizcharts/4.0.14/umd/BizCharts.js',
          'https://cdn.bootcdn.net/ajax/libs/pdf.js/2.2.228/pdf.min.js',
          'https://cdn.bootcdn.net/ajax/libs/pdf.js/2.2.228/pdf.worker.min.js',
          'https://cdn.jsdelivr.net/npm/js-export-excel@1.1.4/lib/index.min.js'
        ],
  // umi routes: https://umijs.org/docs/routing
  routes,
  // Theme for antd: https://ant.design/docs/react/customize-theme-cn
  theme: {
    // ...darkTheme,
    'primary-color': defaultSettings.primaryColor,
  },
  // @ts-ignore
  title: false,
  ignoreMomentLocale: true,
  outputPath: '/pc',
  proxy: {
    '/index/': {
      target: 'https://www.exam.com/',
      changeOrigin: true,
      pathRewrite: { '^/index': '' },
    },
  },

  manifest: {
    basePath: './',
  },
  publicPath: './',
});
